Infra Red Project
By David Empson
Copyright (c) 1994 Apple Users' Group, Sydney
Republished from Applecations, a publication of the Apple Users' Group, Sydney, Australia.
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand
Infra-red Transmitter circuit - notes on operation
Refer to figure 1 for implementation details.
The circuit consists of three main sections:
1. 80 kHz oscillator circuit.
2. Flip-flop to gate and square up the 80 kHz signal and divide by two.
3. Infra-red transmission LEDs.
The oscillator and flip-flop circuit was built from a collection of parts a friend of mine had lying around, so it isn't necessary ideal.
The oscillator consists of two parts: a 4 MHz oscillator (made from a 4 MHz crystal, two resistors, a capacitor and three TTL NAND gates) and a divide-by-50 circuit, using a CD4024 7-stage ripple counter.
When power is applied and the circuit has stabilised, the oscillator will be generating a 4 MHz square wave on the output of the third 74LS00 gate. This is fed into the clock input of the CD4024. The CD4024 is a 7-bit binary counter (0 to 127). The counter stages are available on seven outputs.
The circuit uses diode OR-ing to detect a count value of 50 (32 + 16 + 2). If any of the three bits are set to zero, the corresponding diode will conduct, and the common line (going from the RESET pin of the CD4024 to the clock input of the CD4027) will be held low.
Once all three count outputs go high, none of the diodes will conduct. The pull-up resistor will cause the common line to go high, which will reset the CD4024 to a count value of zero, causing a short pulse on the clock input of the J-K flip-flop. Since the counter is set to zero again, the three output bits will return to zero, clearing the common line.
The J-K flip-flop is a CD4027. We are only using one of the flip-flops in the chip. The J and K inputs are tied high, which causes the flip-flop output to toggle on each clock pulse. This will produce an even 40 kHz square wave on the output.
The SET input of the flip-flop is held low, disabling it. The RESET input of the flip-flop is connected to an annunciator output of the Apple II. Setting the annunciator
output to the high state will hold the flip-flop reset, keeping its Q output in the low state. Setting the annunciator output to the low state will stop resetting the flip-flop, and will allow the output to toggle according to the J-K inputs and the clock pulse.
Thus the annunciator acts as a gating control for the 40 kHz square wave. If the annunciator is low, the square wave will get through. If the annunciator is high, the square wave will be cut off.
This signal is what will be transmitted by the infra-red LEDs. The computer controls the data pulse train by modulating the carrier appropriately.
The resistor on the reset input is an attempt to keep the flip flop reset while the computer is powered down.
The output of the flip-flop goes to the base of the Q1 transistor, via a resistor. There is also a pull-down resistor, which holds the transistor in the "off" state if the oscillator circuit is not powered.
(In my implementation, the oscillator and flip-flop are on one circuit board, and a long pair of wires connects them to the LED transmitter, which is on a second board. The two wires are ground and the flip-flop output.)
If the flip-flop output is high, the transistor will turn on, which will activate the infra-red LEDs (by providing a current path from the 9V battery, through the LEDs, through the transistor to ground). If the flip-flop output is low, the transistor wil l turn off, turning off the LEDs (there is no longer a current path).
The LED circuit uses four LEDs to provide a stronger signal. Each LED produces a voltage drop of about 1.2 volts when conducting. Two LEDs in series will produce a 2.4 volt drop. I use two parallel paths to increase the available current (and LED brightness). R6 and R7 are current limiting resistors. The current through each pair of LEDs will be approximately 24 milliamps. The total current drain from the battery will be approximately 48 milliamps (in short pulses).
The tantalum capacitor provides a charge reserve for when the LEDs
switch on.
Infra-red Receiver circuit - notes on operation
Refer to figure 2 for implementation details.
The receive circuit is unamplified. It can only be used with a short-range signal. From my experiments, the infra-red remote control must be held within a few centimetres of the receiver.
The circuit diagram shows a typical IR signal, and the effect of each stage of the receive circuit. The main purpose of the receive circuit is to detect the presence of the IR carrier signal, and to filter out the 40 kHz component, producing a square wave which indicates "there is an IR signal present".
The receive circuit uses an IR-sensitive diode. The diode conducts when light of an appropriate wavelength illuminates it. It produces a very weak output signal, which must be detected by a precise voltage comparison.
Resistor R1 holds the positive input of the LM393 comparitor low while no IR signal is being detected. When a signal is detected, the diode will conduct, producing a low voltage signal at the positive input of the comparitor (point a). A typical input signal is shown below the circuit diagram.
The negative input of the comparitor is connected to a reference voltage, formed by variable resistor VR1 and resistor R2. This variable resistor must be tuned carefully, so that the comparitor is sensing the IR signal accurately. An oscilloscope should be used to monitor the comparitor output while an IR signal is being presented to the diode. Adjust the variable resistor until the comparitor output is a clean square wave at the correct carrier frequency (about 40 kHz).
The resistor R3 on the output of the comparitor is required because the LM393 has open-collector outputs.
After the first comparitor stage (point b), the input signal forms a square wave at the IR carrier frequency. The square wave will appear in bursts, with the bursts corresponding to the data bits of the IR command code.
The Apple II is not able to sample an input fast enough to accurately read a 40 kHz signal, so the rest of the circuit filters out the 40 kHz component, leaving a low frequency signal which is high while the IR carrier is present, and low while the IR carrier is absent. This signal can be fed into the gating input of the IR transmitter circuit to reproduce the IR command code, or into the computer to be sampled for later playback.
The capacitor C1 and variable resitor VR2 form a low-frequency bandpass filter circuit, which almost eliminates the 40 kHz component (other than "glitches", as shown in the diagram for point c), while leaving the
low-frequency component (the presence or absence of the IR signal) alone.
VR2 must be adjusted so that the "glitches" in the filtered IR signal do not dip too far down (the signal should look somewhat like diagram c while the IR signal is present).
The diode (D1) is required to block any reverse current flow from the capacitor so that it will discharge slowly through VR2, rather than instantly through the first comparitor (while its output is low).
The second comparitor is used to clean up the output from the bandpass filter. VR3 is used to set the comparison voltage. This setting is less critical than the others - it must be set high enough so that a low logic signal comes through as a low, and low enough so that the "glitches" in the filter output are ignored. VR2 and VR3 should be set at the same time, so that a clean square wave is produced on the output.
One final note: the filter causes a delay effect on the falling edge of the "IR present" signal. This is indicated by the arrow in the diagram for point d. The amount of "stretching" is affected by the settings of VR2 and VR3. If the signal is stretched too far, the computer will get an inaccurate time, and may not be able to reproduce the IR signal correctly.
No noticeable stretching occurs on the rising edge, because the capacitor will charge up very quickly.
The second stage comparitor output has another pull-up resistor. The final signal is sent to a switch input in the Apple II, where it can be sampled by an IR receiver program.
Permission is hereby granted for non-profit user groups to republish this content. PLEASE CREDIT THE AUTHOR AND THE SOURCE: Applecations, publication of the Apple Users' Group, Sydney, Australia